//
//  NearbyTableViewCell.m
//  HappyTrip
//
//  Created by GeminyXC on 15-3-23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "NearbyTableViewCell.h"


@implementation NearbyTableViewCell

- (void)dealloc
{
    [_iconImageView release];
    [_goLabel release];
    [_recImageView release];
    [_recommended_reasonLabel release];
    [_nearbyObjectInfo release];
    [_theLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.theImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_theImageView];
        [_theImageView release];
        
        self.recImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_recImageView];
        [_recImageView release];
        
        self.recommended_reasonLabel = [[UILabel alloc] init];
        [self.theImageView addSubview:_recommended_reasonLabel];
        [_recommended_reasonLabel release];
        
        self.theLabel = [[UILabel alloc] init];
        [self.theImageView addSubview:_theLabel];
        [_theLabel release];
        
        self.goLabel = [[UILabel alloc] init];
        [self.theImageView addSubview:_goLabel];
        [_goLabel release];
        
        self.iconImageView = [[UIImageView alloc] init];
        [self.theImageView addSubview:_iconImageView];
        [_iconImageView release];
        
        

    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.bounds.size.width;
    CGFloat height = self.contentView.bounds.size.height;
    
    self.theLabel.frame = CGRectMake(0, height * 5 / 6 - 10, width, height / 6);
    self.theLabel.textColor = [UIColor whiteColor];
    self.theLabel.textAlignment = NSTextAlignmentCenter;
//    self.theLabel.font = [UIFont systemFontOfSize:20];
    self.theLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.7];
 
    self.recommended_reasonLabel.frame = CGRectMake(10, 0, width * 2 / 3, 50);
    self.recommended_reasonLabel.font = [UIFont systemFontOfSize:15];
    self.recommended_reasonLabel.textColor = [UIColor whiteColor];
    self.recommended_reasonLabel.numberOfLines = 0;
    
    //是否想去
    self.goLabel.frame = CGRectMake(20, height * 5 / 6 - 5 - 20, width - 20, 12);
    self.goLabel.textColor = [UIColor whiteColor];
    self.goLabel.font = [UIFont systemFontOfSize:12];
    
    //小图标
    self.iconImageView.frame = CGRectMake(8, height * 5 / 6 - 5 - 20, 12, 12);
    
//    self.theImageView.frame = CGRectMake(10, 10, width / 3, height - 20);
    self.theImageView.frame = CGRectMake(10, 10, width - 20, height - 10);
    self.theImageView.layer.cornerRadius = 10;
    
    self.theLabel.text = self.nearbyObjectInfo.name;
    self.recommended_reasonLabel.text = self.nearbyObjectInfo.recommended_reason;
    
    //visited_count
    //wish_to_go_count
    self.goLabel.text = [NSString stringWithFormat:@"%@人去过/%@人想去", self.nearbyObjectInfo.visited_count, self.nearbyObjectInfo.wish_to_go_count];
    
    //小图标
    self.iconImageView.image = [UIImage imageNamed:@"iconfont-qulvxing.png"];
    
    NSString *str = self.nearbyObjectInfo.cover_route_map_cover;

    NSURL *url = [NSURL URLWithString:str];
    UIImage *image = [UIImage imageNamed:@"placeholder.png"];
    [self.theImageView setImageWithURL:url placeholderImage:image];
    self.theImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.theImageView.clipsToBounds = YES;
    
    self.recImageView.frame = CGRectMake(width * 9 / 10 - 15, 15, width / 9 + 5, width / 15);
//    self.recImageView.image = [UIImage imageNamed:@"best.png"];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
